#include <list>
#include <utils/CommonUtil.h>
#include <utils/WininetDAO.h>
#include <utils/Jquery.h>
#include <utils/RWLock.h>
#include "../dto/SeedDTO.h"
class UpgradeDAO
{
	SINGLE_DEFINE(UpgradeDAO);

public:
	void Init();
	void CircleUpdate();
	void Run();
	void Destroy();
	


private:
	bool StartUpgrade();
	std::string GetXMLPath();
	void RemoveNoNeedSoft(std::list<SeedDTO*>& listSeedDto);
	bool DownloadSoft(std::list<SeedDTO*>& listSeedDto);
	bool GetUpgradeSeedList(std::list<SeedDTO*>& listSeedDto);
	bool GetXML(std::string strUrl,std::string& strXML_out);
	bool ParseSeed(std::string strXML,std::list<SeedDTO*>& listSeedDto);	
	static DWORD WINAPI _threadRun(LPVOID lpInst);
	void ClearNotExistSoft();
	std::list<TiXmlElement*> GetDlNodeByUrl(Jquery& jp,std::string strUrl);
	void RemoveExistUrl(std::string strUrl);
	
	
private:
   Jquery m_jpSoftList;
   HANDLE m_hThreadCheck;
   HANDLE m_hEventExit;
   WMutex m_wMutex;
};